<?php
defined( 'BASEPATH' ) or exit( 'No direct script access allowed' );
class Log_model extends MY_Model
{
    function get_list_count($general = true)
    {
        if ($general)
        {
            $condition = ' AND (b.`role_id`!=1 OR b.`role_id` IS NULL)';
        }
        else
        {
            $condition = '';
        }
        $this->_db->query( "SELECT count(*) FROM `_admin_log_msg` AS a LEFT JOIN `_user` AS b ON b.`id`=a.`uid` WHERE a.`level`<3{$condition}" );
        return ( int ) $this->_db->fetch_cell();
    }
    function get_list($length = 10, $begin = 0, $general = true)
    {
        if ($general)
        {
            $condition = ' AND (b.`role_id`!=1 OR b.`role_id` IS NULL)';
        }
        else
        {
            $condition = '';
        }
        $this->_db->query( "SELECT a.`id`,a.`content`,a.`level`,a.`add_time`,a.`ip`,b.`username`,b.`role_id`,b.`nickname` FROM `_admin_log_msg` AS a LEFT JOIN `_user` AS b ON b.`id`=a.`uid` WHERE a.`level`<3{$condition} ORDER BY a.`add_time` DESC, a.`id` DESC LIMIT {$begin},{$length}" );
        return $this->_db->fetch_all();
    }
}